package com.berchen.schedu.elastic;

import com.dangdang.ddframe.job.config.JobCoreConfiguration;
import com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration;
import com.dangdang.ddframe.job.lite.api.JobScheduler;
import com.dangdang.ddframe.job.lite.config.LiteJobConfiguration;
import com.dangdang.ddframe.job.reg.base.CoordinatorRegistryCenter;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;

public class ElasticJobMain1 {


    public static void main(String[] args){

        // 配置分布式协调服务（注册中心）Zookeeper
        ZookeeperConfiguration zkConfig=new ZookeeperConfiguration("192.168.3.19:2181","data-archivie-job");
        // zookeeper注册中心
        CoordinatorRegistryCenter coordinatorRegistryCenter=new ZookeeperRegistryCenter(zkConfig);
        coordinatorRegistryCenter.init();


        // 配置任务（时间事件、定时任务业务逻辑、调度器）
        JobCoreConfiguration jobConfig = JobCoreConfiguration.newBuilder("chenwh-job", "*/2 * * * * ?", 1).build();
        SimpleJobConfiguration simpleJobConfiguration=new SimpleJobConfiguration(jobConfig,ArchivieJob.class.getName());
        new JobScheduler(coordinatorRegistryCenter,
                LiteJobConfiguration.newBuilder(simpleJobConfiguration)
                        .overwrite(true).   // 数据更改 会重新zookeeper
                        build()
        ).init();
    }
}
